package com.jjb.www.ui.adapter;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;

import androidx.annotation.NonNull;
import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;

import com.hjq.base.BaseAdapter;
import com.hjq.shape.view.ShapeTextView;
import com.hjq.widget.layout.WrapRecyclerView;
import com.jjb.www.R;
import com.jjb.www.app.AppAdapter;
import com.jjb.www.http.api.UserRecordApi;

/**
 *    author : Android CRG
 *    github : https://github.com/getActivity/AndroidProject
 *    time   : 2018/11/05
 *    desc   : 可进行拷贝的副本
 */
public final class EducationAdapter extends AppAdapter<UserRecordApi.Bean.ArrDTO> {
    private EvaluationAdapter evaluationAdapter;
    public EducationAdapter(Context context) {
        super(context);
    }


    @NonNull
    @Override
    public ViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {

        return new ViewHolder();
    }

    private final class ViewHolder extends AppAdapter<?>.ViewHolder {
        private ShapeTextView mTvTitle;
        private ShapeTextView mTvNumber;
        private WrapRecyclerView mRvList;


        private ViewHolder() {
            super(R.layout.item_education);
            mTvTitle = findViewById(R.id.tv_title);
            mRvList = findViewById(R.id.rv_list);
            mTvNumber = findViewById(R.id.tv_number);
            mRvList.setLayoutManager(new LinearLayoutManager(getContext()));
            evaluationAdapter = new EvaluationAdapter(getContext());
            mRvList.setAdapter(evaluationAdapter);
        }

        @Override
        public void onBindView(int position) {
            mTvTitle.setText(getItem(position).getTitle());
            mTvNumber.setText("("+getItem(position).getMyArr().size()+")");
            evaluationAdapter.setData(getItem(position).getMyArr());
        }
    }
}